* Wealth index calculation. Keith Purvis, 10/04/2022. Kenya DHS 2022. * This version is for testing only and drops any asset outside of 5-95%. *cd 'C:\KE81\Wealth '. cd 'C:\Users\21180\OneDrive - ICF\Surveys\KE81\WealthTC4'. include file='wealth_assets.sps'. missing values QH130BN (99.9). missing values QH131BN (99.9). execute. set tvars=both. * Macro definitions to perform some recoding automatically. * Note: Do not use an asterisk in front of a macro name to try to comment it out - it will run any way because of the way the macros are expanded. * Delete the line instead or change the spelling of the macro in the comment. * Do not use the names of macros in comments - they will also be expanded too, and likely will fail. *{Create binary variables based on condition and give label }. define dichotomize( !positional !enclose('(',')') / !positional !tokens(1) / !positional !tokens(1) ) compute !2=0. if (!1) !2=1. variable labels !2 !3. value labels !2 0 'No' 1 'Yes'. formats !2 (f1.0). !enddefine. *(Separate shared toilets from non-shared toilets). define shared_fac( !positional !tokens(1) / !positional !tokens(1) / !positional !tokens(1) ). compute !2 = 0. do if (QH110=1). + if (!1=1) !2 = 1. + compute !1 = 0. end if. variable labels !2 !3. value labels !2 0 'No' 1 'Yes'. formats !2 (f1.0). !enddefine. *{Reset missing values to 'does not have', change 2 code to 0}. define no2zero( !positional !tokens(1) ) if (missing(!1) | !1<>1) !1=0. value labels !1 0 'No' 1 'Yes'. !enddefine. *{Construct Variables}. * Source of drinking water. dichotomize (QH101=11) QH101_11 "Source of drinking water: Piped into dwelling". dichotomize (QH101=12) QH101_12 "Source of drinking water: Piped to yard/plot". dichotomize (QH101=13) QH101_13 "Source of drinking water: Piped to neighbour". dichotomize (QH101=14) QH101_14 "Source of drinking water: Public tap/standpipe". dichotomize (QH101=21) QH101_21 "Source of drinking water: Tube well or borehole". dichotomize (QH101=31) QH101_31 "Source of drinking water: Protected well". dichotomize (QH101=32) QH101_32 "Source of drinking water: Unprotected well". dichotomize (QH101=41) QH101_41 "Source of drinking water: Protected spring". dichotomize (QH101=42) QH101_42 "Source of drinking water: Unprotected spring". dichotomize (QH101=51) QH101_51 "Source of drinking water: Rainwater". dichotomize (QH101=61) QH101_61 "Source of drinking water: Tanker truck". dichotomize (QH101=71) QH101_71 "Source of drinking water: Cart with small tank". dichotomize (QH101=81) QH101_81 "Source of drinking water: Surface water (river/dam/lake/pond/stream/canal/irrigation channel)". dichotomize (QH101=91) QH101_91 "Source of drinking water: Bottled water". dichotomize (QH101=96) QH101_96 "Source of drinking water: Other". * Type of toilet facility. dichotomize (QH109=11) QH109_11 "Type of toilet facility: Flush to piped sewer system". dichotomize (QH109=12) QH109_12 "Type of toilet facility: Flush to septic tank". dichotomize (QH109=13) QH109_13 "Type of toilet facility: Flush to pit latrine". *ichotomize (QH109=14) QH109_14 "Type of toilet facility: Flush to somewhere else". *ichotomize (QH109=15) QH109_15 "Type of toilet facility: Flush, don't know where". dichotomize (QH109=21) QH109_21 "Type of toilet facility: Ventilated improved pit latrine". dichotomize (QH109=22) QH109_22 "Type of toilet facility: Pit latrine with slab". dichotomize (QH109=23) QH109_23 "Type of toilet facility: Pit latrine without slab/open pit". *ichotomize (QH109=31) QH109_31 "Type of toilet facility: Composting toilet". *ichotomize (QH109=41) QH109_41 "Type of toilet facility: Bucket toilet". *ichotomize (QH109=51) QH109_51 "Type of toilet facility: Hanging toilet/hanging latrine". dichotomize (QH109=61) QH109_61 "Type of toilet facility: No facility/bush/field". *ichotomize (QH109=96) QH109_96 "Type of toilet facility: Other". shared_fac QH109_11 QH109_11_sh "Type of toilet facility: Flush to piped sewer system - shared". shared_fac QH109_12 QH109_12_sh "Type of toilet facility: Flush to septic tank - shared". shared_fac QH109_13 QH109_13_sh "Type of toilet facility: Flush to pit latrine - shared". *hared_fac QH109_14 QH109_14_sh "Type of toilet facility: Flush to somewhere else - shared". *hared_fac QH109_15 QH109_15_sh "Type of toilet facility: Flush, don't know where - shared". shared_fac QH109_21 QH109_21_sh "Type of toilet facility: Ventilated improved pit latrine - shared". shared_fac QH109_22 QH109_22_sh "Type of toilet facility: Pit latrine with slab - shared". shared_fac QH109_23 QH109_23_sh "Type of toilet facility: Pit latrine without slab/open pit - shared". *hared_fac QH109_31 QH109_31_sh "Type of toilet facility: Composting toilet - shared". *hared_fac QH109_41 QH109_41_sh "Type of toilet facility: Bucket toilet - shared". *hared_fac QH109_51 QH109_51_sh "Type of toilet facility: Hanging toilet/hanging latrine - shared". *hared_fac QH109_96 QH109_96_sh "Type of toilet facility: Other - shared". * Type of cookstove. *ichotomize (QH117=1) QH117_1 "Type of cookstove: Electric stove". *ichotomize (QH117=2) QH117_2 "Type of cookstove: Solar cooker". dichotomize (QH117=3) QH117_3 "Type of cookstove: Liquefied petroleum gas (LPG)/cooking gas stove". *ichotomize (QH117=4) QH117_4 "Type of cookstove: Piped natural gas stove". *ichotomize (QH117=5) QH117_5 "Type of cookstove: Biogas stove". dichotomize (QH117=6) QH117_6 "Type of cookstove: Liquid fuel stove". dichotomize (QH117=7) QH117_7 "Type of cookstove: Manufactured solid fuel stove (Jiko)". dichotomize (QH117=8) QH117_8 "Type of cookstove: Traditional solid fuel stove". dichotomize (QH117=9) QH117_9 "Type of cookstove: Three stone stove/open fire". dichotomize (QH117=95) QH117_95 "Type of cookstove: No food cooked in household". *ichotomize (QH117=96) QH117_96 "Type of cookstove: Other". * Type of cooking fuel. *ichotomize (QH120=1) QH120_1 "Type of cooking fuel: Alcohol/ethanol". *ichotomize (QH120=2) QH120_2 "Type of cooking fuel: Gasoline/diesel". dichotomize (QH120=3) QH120_3 "Type of cooking fuel: Kerosene/paraffin". *ichotomize (QH120=4) QH120_4 "Type of cooking fuel: Coal/lignite". dichotomize (QH120=5) QH120_5 "Type of cooking fuel: Charcoal". dichotomize (QH120=6) QH120_6 "Type of cooking fuel: Wood". *ichotomize (QH120=7) QH120_7 "Type of cooking fuel: Straw/shrubs/grass". *ichotomize (QH120=8) QH120_8 "Type of cooking fuel: Agricultural crop". *ichotomize (QH120=9) QH120_9 "Type of cooking fuel: Animal dung/waste". *ichotomize (QH120=10) QH120_10 "Type of cooking fuel: Processed biomass (pellets) or woodchips". *ichotomize (QH120=11) QH120_11 "Type of cooking fuel: Garbage/plastic". *ichotomize (QH120=12) QH120_12 "Type of cooking fuel: Sawdust". *ichotomize (QH120=96) QH120_96 "Type of cooking fuel: Other". * Heat source for home. *ichotomize (QH123=1) QH123_1 "Heat source for home: Manufactured space heater". *ichotomize (QH123=2) QH123_2 "Heat source for home: Traditional space heater". *ichotomize (QH123=3) QH123_3 "Heat source for home: Manufactured cookstove". *ichotomize (QH123=4) QH123_4 "Heat source for home: Traditional cookstove (jiko)". *ichotomize (QH123=5) QH123_5 "Heat source for home: Three stone stove/open fire". *ichotomize (QH123=6) QH123_6 "Heat source for home: Fireplace". *ichotomize (QH123=95) QH123_95 "Heat source for home: No heating in household". *ichotomize (QH123=96) QH123_96 "Heat source for home: Other". * Type of fuel for home heat. *ichotomize (QH125=1) QH125_1 "Type of fuel for home heat: Electricity". *ichotomize (QH125=2) QH125_2 "Type of fuel for home heat: Piped natural gas". *ichotomize (QH125=3) QH125_3 "Type of fuel for home heat: Solar air heater". *ichotomize (QH125=4) QH125_4 "Type of fuel for home heat: Liquefied petroleum gas (LPG)/cooking gas". *ichotomize (QH125=5) QH125_5 "Type of fuel for home heat: Biogas". *ichotomize (QH125=6) QH125_6 "Type of fuel for home heat: Alcohol/ethanol". *ichotomize (QH125=7) QH125_7 "Type of fuel for home heat: Gasoline/diesel". *ichotomize (QH125=8) QH125_8 "Type of fuel for home heat: Kerosene/paraffin". *ichotomize (QH125=9) QH125_9 "Type of fuel for home heat: Coal/lignite". dichotomize (QH125=10) QH125_10 "Type of fuel for home heat: Charcoal". dichotomize (QH125=11) QH125_11 "Type of fuel for home heat: Wood". *ichotomize (QH125=12) QH125_12 "Type of fuel for home heat: Straw/shrubs/grass". *ichotomize (QH125=13) QH125_13 "Type of fuel for home heat: Agricultural crop". *ichotomize (QH125=14) QH125_14 "Type of fuel for home heat: Animal dung/waste". *ichotomize (QH125=15) QH125_15 "Type of fuel for home heat: Processed biomass (pellets) or woodchips". *ichotomize (QH125=16) QH125_16 "Type of fuel for home heat: Garbage/plastic". *ichotomize (QH125=17) QH125_17 "Type of fuel for home heat: Sawdust". *ichotomize (QH125=96) QH125_96 "Type of fuel for home heat: Other". * Type of light at home. dichotomize (QH126=1) QH126_1 "Type of light at home: Electricity". dichotomize (QH126=2) QH126_2 "Type of light at home: Solar lantern". dichotomize (QH126=3) QH126_3 "Type of light at home: Rechargeable flashlight, torch, or lantern". dichotomize (QH126=4) QH126_4 "Type of light at home: Battery powered flashlight, torch or lantern". *ichotomize (QH126=5) QH126_5 "Type of light at home: Biogas lamp". *ichotomize (QH126=6) QH126_6 "Type of light at home: Gasoline lamp". dichotomize (QH126=7) QH126_7 "Type of light at home: Kerosene or paraffin lamp". *ichotomize (QH126=8) QH126_8 "Type of light at home: Charcoal". *ichotomize (QH126=9) QH126_9 "Type of light at home: Wood". *ichotomize (QH126=10) QH126_10 "Type of light at home: Straw/shrubs/grass". *ichotomize (QH126=11) QH126_11 "Type of light at home: Agricultural crop". *ichotomize (QH126=12) QH126_12 "Type of light at home: Animal dung/waste". *ichotomize (QH126=13) QH126_13 "Type of light at home: Oil lamp". dichotomize (QH126=14) QH126_14 "Type of light at home: Candle". *ichotomize (QH126=95) QH126_95 "Type of light at home: No lighting in household". *ichotomize (QH126=96) QH126_96 "Type of light at home: Other". * Is the home owned, rented or not paying rent. dichotomize (QH127A=1) QH127A_1 "Is the home owned, rented or not paying rent: Owns". dichotomize (QH127A=2) QH127A_2 "Is the home owned, rented or not paying rent: Pays rent/lease". dichotomize (QH127A=3) QH127A_3 "Is the home owned, rented or not paying rent: No rent with consent of owner". *ichotomize (QH127A=4) QH127A_4 "Is the home owned, rented or not paying rent: No rent, squatting". * Is the land owned. *ichotomize (QH127B=1) QH127B_1 "Is the land owned: Owns". *ichotomize (QH127B=2) QH127B_2 "Is the land owned: Pays rent/lease". *ichotomize (QH127B=3) QH127B_3 "Is the land owned: No rent with consent of owner". *ichotomize (QH127B=4) QH127B_4 "Is the land owned: No rent, squatting". * Cows/bulls. if (missing(QH129A) | QH128 <> 1) QH129A=0. missing values QH129A (99). compute QH129A_1 = (QH129A >= 1 & QH129A <= 2). compute QH129A_2 = (QH129A >= 3 & QH129A <= 5). compute QH129A_3 = (QH129A >= 6 & QH129A <= 98). variable labels QH129A_1 'Cows/bulls: 1-2' /QH129A_2 'Cows/bulls: 3-5' /QH129A_3 'Cows/bulls: 6+'. * Other cattle. if (missing(QH129B) | QH128 <> 1) QH129B=0. missing values QH129B (99). compute QH129B_1 = (QH129B >= 1 & QH129B <= 4). compute QH129B_2 = (QH129B >= 5 & QH129B <= 9). compute QH129B_3 = (QH129B >= 10 & QH129B <= 98). variable labels QH129B_1 'Other cattle: 1-4' /QH129B_2 'Other cattle: 5-9' /QH129B_3 'Other cattle: 10+'. * Horses/donkeys/mules. if (missing(QH129C) | QH128 <> 1) QH129C=0. missing values QH129C (99). compute QH129C_1 = (QH129C >= 1 & QH129C <= 4). compute QH129C_2 = (QH129C >= 5 & QH129C <= 9). compute QH129C_3 = (QH129C >= 10 & QH129C <= 98). variable labels QH129C_1 'Horses/donkeys/mules: 1-4' /QH129C_2 'Horses/donkeys/mules: 5-9' /QH129C_3 'Horses/donkeys/mules: 10+'. * Goats. if (missing(QH129D) | QH128 <> 1) QH129D=0. missing values QH129D (99). compute QH129D_1 = (QH129D >= 1 & QH129D <= 4). compute QH129D_2 = (QH129D >= 5 & QH129D <= 9). compute QH129D_3 = (QH129D >= 10 & QH129D <= 98). variable labels QH129D_1 'Goats: 1-4' /QH129D_2 'Goats: 5-9' /QH129D_3 'Goats: 10+'. * Sheep. if (missing(QH129E) | QH128 <> 1) QH129E=0. missing values QH129E (99). compute QH129E_1 = (QH129E >= 1 & QH129E <= 4). compute QH129E_2 = (QH129E >= 5 & QH129E <= 9). compute QH129E_3 = (QH129E >= 10 & QH129E <= 98). variable labels QH129E_1 'Sheep: 1-4' /QH129E_2 'Sheep: 5-9' /QH129E_3 'Sheep: 10+'. * Chickens or other poultry. if (missing(QH129F) | QH128 <> 1) QH129F=0. missing values QH129F (99). compute QH129F_1 = (QH129F >= 1 & QH129F <= 9). compute QH129F_2 = (QH129F >= 10 & QH129F <= 29). compute QH129F_3 = (QH129F >= 30 & QH129F <= 98). variable labels QH129F_1 'Chickens or other poultry: 1-9' /QH129F_2 'Chickens or other poultry: 10-29' /QH129F_3 'Chickens or other poultry: 30+'. * Pigs. if (missing(QH129G) | QH128 <> 1) QH129G=0. missing values QH129G (99). compute QH129G_1 = (QH129G >= 1 & QH129G <= 4). compute QH129G_2 = (QH129G >= 5 & QH129G <= 9). compute QH129G_3 = (QH129G >= 10 & QH129G <= 98). variable labels QH129G_1 'Pigs: 1-4' /QH129G_2 'Pigs: 5-9' /QH129G_3 'Pigs: 10+'. /* Agricultural land, recoded to square feet */ * Size of agricultural land number. compute landarea = 0. if (QH130BU = 1) landarea = QH130BN*43560. /* acres = 43560 sq ft */ if (QH130BU = 2) landarea = QH130BN*107639. /* hectare = 107639 sq ft */ if (QH130BU = 3) landarea = QH130BN. /* square feet */ if ((QH130BU = 1 or QH130BU = 2) and QH130BN = 995) landarea = 950000. if (QH130BU = 3 and QH130BN = 999995) landarea = 950000. if (landarea > 950000) landarea = 950000. if (QH130BU >= 8) landarea = 0. if (missing(QH130BN) | QH130BN >= 999999.8) landarea=999999. if (missing(QH130A ) | QH130A <> 1) landarea=0. missing values landarea (999999). /* Non-Agricultural land, recoded to square feet */ * Size of non-agricultural land number. compute landarea2 = 0. if (QH131BU = 1) landarea2 = QH131BN*43560. /* acres = 43560 sq ft */ if (QH131BU = 2) landarea2 = QH131BN*107639. /* hectare = 107639 sq ft */ if (QH131BU = 3) landarea2 = QH131BN. /* square feet */ if ((QH131BU = 1 or QH131BU = 2) and QH131BN = 995) landarea2 = 950000. if (QH131BU = 3 and QH131BN = 999995) landarea2 = 950000. if (landarea2 > 950000) landarea2 = 950000. if (QH131BU >= 8) landarea2 = 0. if (missing(QH131BN) | QH131BN >= 999999.8) landarea2=999999. if (missing(QH131A ) | QH131A <> 1) landarea2=0. missing values landarea2 (999999). * capture the cases with missing landarea that are to be replacced by means. compute misland = missing(landarea). compute misland2 = missing(landarea2). freq misland misland2. * Electricity. no2zero QH132A. * Radio. no2zero QH132B. * Television. no2zero QH132C. * Telephone (non-mobile). no2zero QH132D. * Computer. no2zero QH132E. * Refrigerator. no2zero QH132F. * Solar Panel. no2zero QH132G. * Table. no2zero QH132H. * Chair. no2zero QH132I. * Sofa. no2zero QH132J. * Bed. no2zero QH132K. * Cupboard. no2zero QH132L. * Clock. no2zero QH132M. * Microwave oven. no2zero QH132N. * DVD player. no2zero QH132O. * Cassette or CD player. no2zero QH132P. * Watch. no2zero QH133A. * Bicycle. no2zero QH133C. * Motorcycle or scooter. no2zero QH133D. * Animal-drawn cart. no2zero QH133E. * Car or Truck. no2zero QH133F. * Boat with a motor. no2zero QH133G. * Household registered to a mobile money platform. no2zero QH134D. * Main floor material. dichotomize (QH152=11) QH152_11 "Main floor material: Earth/sand". dichotomize (QH152=12) QH152_12 "Main floor material: Dung". *ichotomize (QH152=21) QH152_21 "Main floor material: Wood planks". *ichotomize (QH152=22) QH152_22 "Main floor material: Palm/bamboo". *ichotomize (QH152=31) QH152_31 "Main floor material: Parquet or polished wood". *ichotomize (QH152=32) QH152_32 "Main floor material: Vinyl or asphalt strips". dichotomize (QH152=33) QH152_33 "Main floor material: Ceramic tiles". dichotomize (QH152=34) QH152_34 "Main floor material: Cement". dichotomize (QH152=35) QH152_35 "Main floor material: Carpet". *ichotomize (QH152=96) QH152_96 "Main floor material: Other". * Main roof material. *ichotomize (QH153=11) QH153_11 "Main roof material: No roof". dichotomize (QH153=12) QH153_12 "Main roof material: Thatch/grass/makuti". *ichotomize (QH153=13) QH153_13 "Main roof material: Sod/mud/dung". *ichotomize (QH153=21) QH153_21 "Main roof material: Rustic mat". *ichotomize (QH153=22) QH153_22 "Main roof material: Palm/bamboo". *ichotomize (QH153=23) QH153_23 "Main roof material: Wood planks". *ichotomize (QH153=24) QH153_24 "Main roof material: Cardboard". *ichotomize (QH153=25) QH153_25 "Main roof material: Tin cans". dichotomize (QH153=31) QH153_31 "Main roof material: Iron sheets/Metal". *ichotomize (QH153=32) QH153_32 "Main roof material: Wood". *ichotomize (QH153=33) QH153_33 "Main roof material: Calamine/cement fiber". *ichotomize (QH153=34) QH153_34 "Main roof material: Ceramic tiles". dichotomize (QH153=35) QH153_35 "Main roof material: Cement". *ichotomize (QH153=36) QH153_36 "Main roof material: Roofing shingles". *ichotomize (QH153=37) QH153_37 "Main roof material: Asbestos sheet". *ichotomize (QH153=96) QH153_96 "Main roof material: Other". * Main wall material. *ichotomize (QH154=11) QH154_11 "Main wall material: No walls". dichotomize (QH154=12) QH154_12 "Main wall material: Cane/palm/trunks". dichotomize (QH154=13) QH154_13 "Main wall material: Dirt". dichotomize (QH154=21) QH154_21 "Main wall material: Bamboo with mud". dichotomize (QH154=22) QH154_22 "Main wall material: Stone with mud". dichotomize (QH154=23) QH154_23 "Main wall material: Uncovered adobe". *ichotomize (QH154=24) QH154_24 "Main wall material: Plywood". *ichotomize (QH154=25) QH154_25 "Main wall material: Cardboard". dichotomize (QH154=26) QH154_26 "Main wall material: Reused wood". dichotomize (QH154=27) QH154_27 "Main wall material: Iron sheets". dichotomize (QH154=31) QH154_31 "Main wall material: Cement". dichotomize (QH154=32) QH154_32 "Main wall material: Stone with lime/cement". dichotomize (QH154=33) QH154_33 "Main wall material: Bricks". dichotomize (QH154=34) QH154_34 "Main wall material: Cement blocks". dichotomize (QH154=35) QH154_35 "Main wall material: Covered adobe". dichotomize (QH154=36) QH154_36 "Main wall material: Wood planks/shingles". dichotomize (QH154=96) QH154_96 "Main wall material: Other". *{Members per sleeping room}. if (hhusual=0) hhusual=hhslept. * to match KNBS version which is rounded to 1 decimal. 0.5 is to produce rounded instead of truncated numbers. if (QH127>0) memsleep=trunc((hhusual/QH127)+0.5). *if (QH127>0) memsleep=trunc((10*hhusual/QH127)+0.5)/10. if (QH127=0) memsleep=hhusual. if (missing(QH127) or QH127>=99 or memsleep>=98) memsleep=99. variable labels memsleep 'Number of members per sleeping room'. value labels memsleep 0 'Less than 1 per room'. formats memsleep (f4.1). missing values memsleep (99). * Compute urban and rural variables coded (1/0) for filters later. compute urban=(QHTYPE = 1). compute rural=(QHTYPE = 2). variable labels urban 'Urban' / rural 'Rural'. value labels urban 1 'Urban' / rural 1 'Rural'. formats urban rural (f1.0). execute. * Check on computation of memsleep. means memsleep by urban. * Check on indicator variable creation. frequencies variables=QHTYPE to land. * Toilet facility by shared/not shared. crosstabs /tables=QH109 by QH110. * agricultural Land area by units - if there are separate units - need to convert them to one unit. crosstabs /tables=QH130BN by QH130BU. * non-agricultural Land area by units - if there are separate units - need to convert them to one unit. crosstabs /tables=QH131BN by QH131BU. frequencies variables= QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH129A_1 QH129A_2 QH129A_3 QH129B_1 QH129B_2 QH129C_1 QH129D_1 QH129D_2 QH129D_3 QH129E_1 QH129E_2 QH129E_3 QH129F_1 QH129F_2 QH129F_3 QH129G_1 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133B QH133C QH133D QH133E QH133F QH134D QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 landarea landarea2 memsleep MOBPHONE CHECKACC HOUSE . * Turn off weights before all factor analysis. weight off. * Name the dataset window for the HH data for use later. dataset name assets. save outfile='assets.sav'. * Calculate means for landarea variables by urban/rural. weight off. filter off. * Calculate means for landarea variables for substitution. aggregate outfile=* mode=addvariables /break = urban /mn_land = mean(landarea) /mn_land2 = mean(landarea2). * Substitute missing with means. if (misland = 1) landarea = mn_land. if (misland2 = 1) landarea2 = mn_land2. *** Test Factor Analysis. filter off. execute. factor /variables QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH129A_1 QH129A_2 QH129A_3 QH129B_1 QH129B_2 QH129C_1 QH129D_1 QH129D_2 QH129D_3 QH129E_1 QH129E_2 QH129E_3 QH129F_1 QH129F_2 QH129F_3 QH129G_1 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 landarea landarea2 memsleep HOUSE /missing meansub /analysis QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH129A_1 QH129A_2 QH129A_3 QH129B_1 QH129B_2 QH129C_1 QH129D_1 QH129D_2 QH129D_3 QH129E_1 QH129E_2 QH129E_3 QH129F_1 QH129F_2 QH129F_3 QH129G_1 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 landarea landarea2 memsleep HOUSE /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /method=correlation. *** Common Factor analysis ***. ** Removed area-specific variables **. ** Agricultural animal variables excluded ** Land area excluded *** Common Factor Analysis. filter off. execute. * QH101_91 QH101_96 dropped by mistake?. factor /variables QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh landarea2 memsleep HOUSE /missing meansub /analysis QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh landarea2 memsleep HOUSE /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /save reg(ALL com) /method=correlation. *** Urban Factor Analysis. filter off. filter by urban. execute. factor /variables QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh landarea2 memsleep HOUSE /missing meansub /analysis QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh landarea2 memsleep HOUSE /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /save reg(ALL urb) /method=correlation. *** Rural Factor Analysis. filter off. filter by rural. execute. factor /variables QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH129A_1 QH129A_2 QH129A_3 QH129B_1 QH129B_2 QH129C_1 QH129D_1 QH129D_2 QH129D_3 QH129E_1 QH129E_2 QH129E_3 QH129F_1 QH129F_2 QH129F_3 QH129G_1 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh landarea memsleep HOUSE /missing meansub /analysis QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH129A_1 QH129A_2 QH129A_3 QH129B_1 QH129B_2 QH129C_1 QH129D_1 QH129D_2 QH129D_3 QH129E_1 QH129E_2 QH129E_3 QH129F_1 QH129F_2 QH129F_3 QH129G_1 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134D MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh landarea memsleep HOUSE /print univariate initial extraction fscore /criteria factors(1) iterate(25) /extraction pc /rotation norotate /save reg(ALL rur) /method=correlation. * Label the created score variables. rename variables (com1 urb1 rur1=comscore urbscore rurscore). variable labels comscore 'Common wealth score' /urbscore 'Urban wealth score' /rurscore 'Rural wealth score'. * Add a variable used for linking later. filter off. string rowtype_ (A8). compute rowtype_ = 'EST'. * Calculate regressions. ** Area=urban. filter off. filter by urban. execute. * Declare a dataset to be written to in the regression. dataset declare urbancorv. * Run regression of comscore with urbscore. regression /missing listwise /statistics coeff outs R anova /criteria=pin(.05) pout(.10) /noorigin /dependent comscore /method=enter urbscore /outfile=corv(urbancorv). * Activate file of output from regression. dataset activate urbancorv. * Drop all rows of output except the coefficients. select if (rowtype_ = 'EST'). execute. * Delete unnecessary variables before merging. delete variables DEPVAR_ VARNAME_. * Rename variables containing the constant and the coefficient. rename variables CONST_=urbconst urbscore=urbcoeff. * Re-activate the main household data. dataset activate assets. * merge the coefficients. match files /file = * /table = urbancorv /by ROWTYPE_. execute. * Calculate regressions. ** Area=rural. filter off. filter by rural. execute. * Declare a dataset to be written to in the regression. dataset declare ruralcorv. * Run regression of comscore with rurscore. regression /missing listwise /statistics coeff outs R anova /criteria=pin(.05) pout(.10) /noorigin /dependent comscore /method=enter rurscore /outfile=corv(ruralcorv). * Activate file of output from regression. dataset activate ruralcorv. * Drop all rows of output except the coefficients. select if (rowtype_ = 'EST'). execute. * Delete unnecessary variables before merging. delete variables DEPVAR_ VARNAME_. * Rename variables containing the constant and the coefficient. rename variables CONST_=rurconst rurscore=rurcoeff. * Re-activate the main household data. dataset activate assets. * merge the coefficients. match files /file = * /table = ruralcorv /by ROWTYPE_. execute. dataset close urbancorv. dataset close ruralcorv. dataset activate assets. filter off. *** Calculate combined wealth score from Urban and Rural Scores. * Use coefficients from urban and rural regressions above. compute combscor=0. print formats combscor (f11.5). write formats combscor (f11.5). ** Urban. if (urban = 1) combscor=urbconst+urbcoeff*urbscore. ** Rural. if (rural = 1) combscor=rurconst+rurcoeff*rurscore. variable labels combscor 'Combined national wealth score'. execute. compute hhwt = QHWEIGHT/1000000. variable labels hhwt 'HH weights'. formats hhwt (f12.6). weight by hhwt. filter off. execute. frequencies variables=combscor comscore /format=notable /ntiles=5 /statistics=minimum maximum stddev mean /histogram normal /order=analysis. filter off. filter by urban. execute. frequencies variables=combscor urbscore /format=notable /ntiles=5 /statistics=minimum maximum stddev mean /histogram normal /order=analysis. filter off. filter by rural. execute. frequencies variables=combscor rurscore /format=notable /ntiles=5 /statistics=minimum maximum stddev mean /histogram normal /order=analysis. filter off. execute. *Calculate quintiles and scores for data file. compute hhmemwt=QHWEIGHT*hhusual/1000000. variable labels hhmemwt 'HH members weighting for index'. formats hhmemwt (f12.6). weight by hhmemwt. filter off. filter by urban. execute. rank variables=urbscore (A) /rank /ntiles (5) /print=yes /ties=low. filter off. filter by rural. execute. rank variables=rurscore (A) /rank /ntiles (5) /print=yes /ties=low. filter off. execute. rank variables=combscor (A) /rank /ntiles (5) /print=yes /ties=low. variable labels ncombsco 'Combined wealth index' /nurbscor 'Urban wealth index' /nrurscor 'Rural wealth index'. value labels ncombsco nurbscor nrurscor 1 'Lowest' 2 'Second' 3 'Middle' 4 'Fourth' 5 'Highest'. *** Check on quintiles. frequencies variables=ncombsco nurbscor nrurscor. weight by hhwt. ctables /table ( QH101_11+QH101_12+QH101_13+QH101_14+QH101_21+QH101_31+QH101_32+QH101_41+QH101_42+QH101_51+QH101_61+QH101_71+QH101_81+QH101_91+QH101_96+ QH109_11+QH109_12+QH109_13+QH109_21+QH109_22+QH109_23+QH109_61+ QH109_11_sh+QH109_12_sh+QH109_13_sh+QH109_21_sh+QH109_22_sh+QH109_23_sh+QH117_3+QH117_6+QH117_7+QH117_8+QH117_9+QH117_95+ QH120_3+QH120_5+QH120_6+QH125_10+QH125_11+QH126_1+QH126_2+QH126_3+QH126_4+QH126_7+QH126_14+QH127A_1+QH127A_2+QH127A_3+ QH129A_1+QH129A_2+QH129A_3+QH129B_1+QH129B_2+ QH129C_1+QH129D_1+QH129D_2+QH129D_3+ QH129E_1+QH129E_2+QH129E_3+QH129F_1+QH129F_2+QH129F_3+QH129G_1+ QH132A+QH132B+QH132C+QH132D+QH132E+QH132F+QH132G+QH132H+QH132I+QH132J+QH132K+QH132L+QH132M+QH132N+QH132O+QH132P+ QH133A+QH133C+QH133D+QH133E+QH133F+QH134+MOBPHONE+CHECKACC+ QH152_11+QH152_12+QH152_33+QH152_34+QH152_35+ QH153_12+QH153_31+QH153_35+ QH154_12+QH154_13+QH154_21+QH154_22+QH154_23+QH154_26+QH154_27+QH154_31+QH154_32+QH154_33+QH154_34+QH154_35+QH154_36+QH154_96+ landarea+landarea2+memsleep+HOUSE )[S][Mean F8.3] by (ncombsco+nurbscor+nrurscor)[C] /slabels visible=no. * Alternative instead of ctables. *means tables= QH101_11 QH101_12 QH101_13 QH101_14 QH101_21 QH101_31 QH101_32 QH101_41 QH101_42 QH101_51 QH101_61 QH101_71 QH101_81 QH101_91 QH101_96 QH109_11 QH109_12 QH109_13 QH109_21 QH109_22 QH109_23 QH109_61 QH109_11_sh QH109_12_sh QH109_13_sh QH109_21_sh QH109_22_sh QH109_23_sh QH117_3 QH117_6 QH117_7 QH117_8 QH117_9 QH117_95 QH120_3 QH120_5 QH120_6 QH125_10 QH125_11 QH126_1 QH126_2 QH126_3 QH126_4 QH126_7 QH126_14 QH127A_1 QH127A_2 QH127A_3 QH129A_1 QH129A_2 QH129A_3 QH129B_1 QH129B_2 QH129C_1 QH129D_1 QH129D_2 QH129D_3 QH129E_1 QH129E_2 QH129E_3 QH129F_1 QH129F_2 QH129F_3 QH129G_1 QH132A QH132B QH132C QH132D QH132E QH132F QH132G QH132H QH132I QH132J QH132K QH132L QH132M QH132N QH132O QH132P QH133A QH133C QH133D QH133E QH133F QH134 MOBPHONE CHECKACC QH152_11 QH152_12 QH152_33 QH152_34 QH152_35 QH153_12 QH153_31 QH153_35 QH154_12 QH154_13 QH154_21 QH154_22 QH154_23 QH154_26 QH154_27 QH154_31 QH154_32 QH154_33 QH154_34 QH154_35 QH154_36 QH154_96 landarea landarea2 memsleep HOUSE by ncombsco nurbscor nrurscor /cells mean count stddev. graph /histogram(normal)=combscor /title= 'Distribution of Households by Wealth Scores'. frequencies variables=combscor /format=notable /ntiles=5 /statistics=stddev minimum maximum semean mean median mode skewness seskew kurtosis sekurt /order=analysis. weight off. filter off. write formats combscor urbscore rurscore (f11.5). * Save final dataset of assets. save outfile='assets.sav'. *** Write out scores file. write outfile='scores.dat' table /QHCLUST QHNUMBER combscor ncombsco urbscore nurbscor rurscore nrurscor. execute. value labels QHREGION 1 "Mombasa" 2 "Kwale" 3 "Kilifi" 4 "Tana River" 5 "Lamu" 6 "Taita Taveta" 7 "Garissa" 8 "Wajir" 9 "Mandera" 10 "Marsabit" 11 "Isiolo" 12 "Meru" 13 "Tharaka Nithi" 14 "Embu" 15 "Kitui" 16 "Machakos" 17 "Makueni" 18 "Nyandarua" 19 "Nyeri" 20 "Kirinyaga" 21 "Murang'a" 22 "Kiambu" 23 "Turkana" 24 "West Pokot" 25 "Samburu" 26 "Trans Nzoia" 27 "Uasin Gishu" 28 "Elgeyo Marakwet" 29 "Nandi" 30 "Baringo" 31 "Laikipia" 32 "Nakuru" 33 "Narok" 34 "Kajiado" 35 "Kericho" 36 "Bomet" 37 "Kakamega" 38 "Vihiga" 39 "Bungoma" 40 "Busia" 41 "Siaya" 42 "Kisumu" 43 "Homa Bay" 44 "Migori" 45 "Kisii" 46 "Nyamira" 47 "Nairobi" . * Produce table 2.6 weighted by de jure population to test. weight by hhmemwt. compute total = 0. variable labels total 'Total'. value labels total 0 ' '. ctables /vlabels variables=QHTYPE QHREGION total Ncombsco display=both /table QHTYPE [C] + QHREGION [C] + total [C] BY Ncombsco [C][rowpct.count '%' F8.1, totals [rowpct.count '%' F8.1, count '' F8.0]] /categories variables=Ncombsco total=yes /titles title='Table 2.6 Wealth Quintiles' '' 'Percent distribution of the de jure population by wealth quintiles, according to residence and region, Kenya DHS 2022' corner='Residence/region' /slabels visible=no.